We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to access to related models in volt with find(array('columns => ...'))

Hello,

I would like to be able in Volt to access to the related models. If I type Users::find(), I can access to the related model by typing in my Volt view {{ users.getRoles.name }}.

However, when if I type Users::find(array('columns' => 'firstname, lastname, email, roleid')). It doesn't work anymore.

Could you tell me why ? How to do it. I would like to send not all of the field, only the field needed. I would prefer to use ORM instead of a simple array with PDO statement.

Thanks

Just a thought but since the query didn't work using the columns filter it may be occuring because you didn't include the users.id in the column request.

Perhaps update to Users::find(array('columns' => 'id', 'firstname, lastname, email, roleid')) //where id is whatever your mapped field for Roles is to Users relation.